package com.dovgopoly.carlogbook.services.impl;

import org.springframework.stereotype.Service;

import com.dovgopoly.carlogbook.services.GreetingService;
import com.dovgopoly.carlogbook.web.shared.FieldVerifier;

/**
 * The server side implementation of the RPC service.
 */
@Service("greetingService")
public class GreetingServiceImpl implements GreetingService {

	public String greetServer(String input) throws IllegalArgumentException {
		// Verify that the input is valid.
		if (!FieldVerifier.isValidName(input)) {
			// If the input is not valid, throw an IllegalArgumentException back
			// to
			// the client.
			throw new IllegalArgumentException("Name must be at least 4 characters long");
		}

		return "Hello, " + input + "!<br><br>I am running " + input + ".<br><br>It looks like you are using:<br>";
	}

}
